﻿using System.Collections.Generic;

/// <summary>
/// The Util Class of control the data structure
/// </summary>
public class DataStructureUtil
{
    public static Dictionary<int, T> ResetDictionary<T>(Dictionary<int, T> dict, int capacity = 0)
    {
        if (dict == null)
        {
            return new Dictionary<int, T>(capacity);
        }
        dict.Clear();
        return new Dictionary<int, T>(capacity);
    }

    public static Dictionary<string, T> ResetDictionary<T>(Dictionary<string, T> dict, int capacity = 0)
    {
        if (dict == null)
        {
            return new Dictionary<string, T>(capacity);
        }
        dict.Clear();
        return new Dictionary<string, T>(capacity);
    }

    public static List<T> ResetList<T>(List<T> list, int capacity = 0)
    {
        if (list == null)
        {
            return new List<T>(capacity);
        }
        list.Clear();
        return new List<T>(capacity);
    }
}
